Address NRT review feedback and clear remaining warnings - #164
Address NRT review feedback and clear remaining warnings#164imnasnainaec wants to merge 2 commits into
Conversation
- MapToExistingLanguageIfPossible now returns the empty string (not null) for empty input, honoring its [return: NotNullIfNotNull] contract. - Removed the incorrect [MemberNotNullWhen(false, Id, Source, Target)] from XLiffTransUnit.IsEmpty: IsEmpty is a conjunction, so !IsEmpty does not imply all three members are non-null. Adjusted ToString and XLiffBody.AddTransUnitRaw, which relied on that bogus guarantee. - DefaultInstalledStringFilePath now throws a clear InvalidOperationException instead of passing a possibly-null folder to Path.Combine. - StringCache is backed by a nullable field and throws a clear InvalidOperationException instead of being `null!` and NREing when the minimal constructor was used. - MergeXliffDocuments hoists the trans-unit id once per iteration and skips units without one, replacing ten null-forgiving `tu.Id!` uses. - Fixed the four remaining warnings: CS8604 in XLiffBody (hoisted documented locals) and CS8618 for DefaultStringFilePath (defaults to string.Empty). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
hahn-kev
left a comment
There was a problem hiding this comment.
I'd like to fix the 2 tu.Id! overrides we have as that only holds true if the methods which set the Id never change. I'd opt to throw so we catch the issue early, but if that is highly likely to bubble up to the user then I'd probably avoid that. But we could always just add a test for each that would catch the error in CI.
| return; | ||
|
|
||
| // GetTransUnitForId returns null for a null id, so existingTu proves tu.Id isn't. | ||
| var id = tu.Id!; |
There was a problem hiding this comment.
While this works it means that if GetTransUnitForId were to change then this wouldn't work anymore. I say we either throw if id is null, or we return. This is similar to what we do in some places below. Hard to say what the right choice is here, I'd probably throw if this would likely be caught in tests. The same applies to AddTransUnit above.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
I went a slightly different direction in 9128cec. What do you think?
In place of the long-winded AI-drafted reviews I posted on #157, I offer this pr pr.
This change is